import {
  clientListReq
} from "@/requests/clientRequests";

import {
  orderListReq
} from '@/requests/orderRequests.js';

import {
  deliveryListReq
} from '@/requests/deliveryRequests.js';

import * as types from "./mutation_types";

export default {
  [types.UPDATECLIENTS](state) {
    clientListReq().then((res) => {
      const clients = res.data;
      state.clientsCache = clients;
      console.log(`更新客户缓存`, clients);
    }).catch((err) => {
      this.$notification['error']({
        message: '总页面',
        description:
          `更新客户缓存失败，失败信息 ${err.response.data.message}`,
      });
    });
  },
  [types.UPDATEORDERS](state) {
    orderListReq().then((res) => {
      const orders = res.data;
      state.ordersCache = orders;
      console.log(`更新订单缓存`, orders);
    }).catch((err) => {
      this.$notification['error']({
        message: '总页面',
        description:
          `更新订单缓存失败，失败信息 ${err.response.data.message}`,
      });
    });
  },
  [types.UPDATEDELIVERIES](state) {
    deliveryListReq().then((res) => {
      const deliveries = res.data;
      state.deliveriesCache = deliveries;
      console.log(`更新送货单缓存`, deliveries);
    }).catch((err) => {
      this.$notification['error']({
        message: '总页面',
        description:
          `更新送货单缓存失败，失败信息 ${err.response.data.message}`,
      });
    });
  },
  [types.LOGIN]: (state, value) => {
    state.token = value
  },
  [types.USERINFO]: (state, info) => {
    state.userInfo = info
  },
  [types.LOGINSTATUS]: (state, bool) => {
    state.loginStatus = bool
  },
  
}